package com.ecnu.web.controller.project;

import com.ecnu.common.annotation.Log;
import com.ecnu.common.core.controller.BaseController;
import com.ecnu.common.core.domain.AjaxResult;
import com.ecnu.common.core.page.TableDataInfo;
import com.ecnu.common.enums.BusinessType;
import com.ecnu.system.domain.ProjectNotice;
import com.ecnu.system.service.IProjectNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 公告 信息操作处理
 * 
 * @author ruoyi
 */
@RestController
@RequestMapping("/project/notice")
public class ProjectNoticeController extends BaseController
{
    @Autowired
    private IProjectNoticeService noticeService;

    /**
     * 新增活动通知公告
     */
    @PreAuthorize("@ss.hasPermi('project:notice:add')")
    @Log(title = "通知公告", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@Validated @RequestBody ProjectNotice notice)
    {
        notice.setCreateBy(getUsername());
        return toAjax(noticeService.insertNotice(notice));
    }
    @PreAuthorize("@ss.hasPermi('project:notice:list')")
    @Log(title = "通知公告", businessType = BusinessType.INSERT)
    @GetMapping("/list")
    public AjaxResult list(@PathVariable Long projectId)
    {
        return success(noticeService.selectNoticeByProjectId(projectId));
    }

}
